public void SetProperties(CkanPackage unsavedPackage, CkanGroup ckanGroup, ProfileParameters parameters,
     IndicatorMetadata indicatorMetadata, TimeRange timeRange)
 {
     SetMetadataProperties(unsavedPackage, indicatorMetadata);
     SetPackageProperties(unsavedPackage, ckanGroup, parameters);
     SetDateProperties(unsavedPackage, timeRange);
 }
 public CkanGroup UpdateGroupWithProfileProperties(Profile profile, CkanGroup ckanGroup)
 {
     SetProperties(ckanGroup, profile);
     if (profile != null)
     {
         ckanGroup = _ckanApi.UpdateGroup(ckanGroup);
     }
     return ckanGroup;
 }
        public void TestUsersIsNotSerializedWhenNull()
        {
            var group = new CkanGroup
            {
                Users = new List<CkanUser> { }
            };

            var json = JsonConvert.SerializeObject(group);

            Assert.IsFalse(json.Contains(JsonSubstringUsers));
        }
        public void TestUsersIsSerializedWhenNotEmpty()
        {
            var group = new CkanGroup
            {
                Users = new List<CkanUser> { new CkanUser{Name="a"}}
            };

            var json = JsonConvert.SerializeObject(group);

            Assert.IsTrue(json.Contains(JsonSubstringUsers));
            Assert.IsTrue(json.Contains("\"name\":\"a\""));
        }
        public void TestCreateGroup()
        {
            var group = new CkanGroup();
            group.Name = GroupName;
            group.Title = "Public Health Outcomes Framework";
            group.Description = Description;
            var ckanGroup = CkanApi().CreateGroup(group);

            // Check group
            Assert.IsNotNull(ckanGroup);
            Assert.AreEqual(Description, ckanGroup.Description);
        }
 private static void SetPackageProperties(CkanPackage package, 
     CkanGroup group, ProfileParameters parameters)
 {
     string homePage = parameters.ProfileUrl;
     package.Source = homePage;
     package.Homepage = homePage;
     package.LicenseId = parameters.LicenceId;
     string emailAddress = AuthorDetails.GetEmailAddress(parameters.ProfileId);
     package.Author = emailAddress;
     package.AuthorEmail = emailAddress;
     package.Maintainer = emailAddress;
     package.MaintainerEmail = emailAddress;
     package.OwnerOrganization = parameters.OrganisationId;
     package.Resources = new List<CkanResource>();
     package.Groups = new List<CkanGroup> { @group.GetMinimalGroupForSendingToCkan() };
 }
        private CkanGroup CreateOrRetrieveGroup(string groupId, Profile profile)
        {
            CkanGroup ckanGroup;
            try
            {
                ckanGroup = _ckanApi.GetGroup(groupId);
                if (ckanGroup == null)
                {
                    // Create new group
                    var unsavedCkanGroup = new CkanGroup
                    {
                        Name = groupId,
                    };
                    SetProperties(unsavedCkanGroup, profile);
                    ckanGroup = _ckanApi.CreateGroup(unsavedCkanGroup);
                }
            }
            catch (Exception ex)
            {
                if (ex is CkanTimeoutException || ex is CkanInternalServerException)
                {
                    ckanGroup = null;

                    if (WaitIfResourceUploadFails)
                    {
                        // Wait 10s before continuing
                        Thread.Sleep(1000 * 10);
                    }
                }
                else
                {
                    throw;
                }
            }
            return ckanGroup;
        }
        private void SetProperties(CkanGroup ckanGroup, Profile profile)
        {
            if (profile != null)
            {
                var profileName = profile.Name;
                var description = _contentProvider
                    .GetContentWithHtmlRemoved(profile.Id, ContentKeys.CkanDescription);

                ckanGroup.Title = profileName;
                ckanGroup.Description = description;
            }
        }
 public static void ClassInitialize(TestContext context)
 {
     var ckanApi = CkanTestHelper.CkanApi();
     ckanGroup = ckanApi.GetGroup(GroupName);
 }