Example #1
0
    def test_nerdm_record_withannots(self):
        self.bag = bag.NISTBag(metabagdir)
        nerd = self.bag.nerdm_record()

        self.assertNotIn('authors', nerd)
        self.assertTrue(nerd['title'].startswith("OptSortSph: Sorting "))
        self.assertEqual(nerd['ediid'], "3A1EE2F169DD3B8CE0531A570681DB5D1491")
        self.assertEqual(nerd['@type'], ["nrdp:PublicDataResource"])
        trial1 = [
            c for c in nerd['components']
            if 'filepath' in c and c['filepath'] == "trial1.json"
        ][0]
        self.assertNotIn('previewURL', trial1)

        nerd = self.bag.nerdm_record(True)

        self.assertIn('authors', nerd)
        self.assertTrue(nerd['title'].startswith("OptSortSph: Sorting "))
        self.assertEqual(nerd['ediid'], "3A1EE2F169DD3B8CE0531A570681DB5D1491")

        self.assertEqual(nerd['authors'][0]['givenName'], "Kevin")
        self.assertEqual(nerd['authors'][1]['givenName'], "Jianming")
        self.assertEqual(len(nerd['authors']), 2)
        self.assertEqual(nerd['@type'],
                         ["nrdp:DataPublication", "nrdp:PublicDataResource"])

        trial1 = [
            c for c in nerd['components']
            if 'filepath' in c and c['filepath'] == "trial1.json"
        ][0]
        self.assertIn('previewURL', trial1)
        self.assertTrue(trial1['previewURL'].endswith("trial1.json/preview"))
Example #2
0
    def test_nerd_metadata_for_withannots(self):
        self.bag = bag.NISTBag(metabagdir)

        nerd = self.bag.nerd_metadata_for("")
        self.assertNotIn('authors', nerd)
        self.assertNotIn('foo', nerd)
        self.assertTrue(nerd['title'].startswith("OptSortSph: Sorting "))
        self.assertEqual(nerd['ediid'], "3A1EE2F169DD3B8CE0531A570681DB5D1491")
        self.assertEqual(nerd['@type'], ["nrdp:PublicDataResource"])

        nerd = self.bag.nerd_metadata_for("", True)
        self.assertIn('authors', nerd)
        self.assertTrue(nerd['title'].startswith("OptSortSph: Sorting "))
        self.assertEqual(nerd['ediid'], "3A1EE2F169DD3B8CE0531A570681DB5D1491")
        self.assertIn('foo', nerd)
        self.assertIn(nerd['foo'], "bar")
        self.assertEqual(nerd['authors'][0]['givenName'], "Kevin")
        self.assertEqual(nerd['authors'][1]['givenName'], "Jianming")
        self.assertEqual(len(nerd['authors']), 2)
        self.assertEqual(nerd['@type'],
                         ["nrdp:DataPublication", "nrdp:PublicDataResource"])

        nerd = self.bag.nerd_metadata_for("trial1.json")
        self.assertNotIn("previewURL", nerd)
        self.assertTrue(nerd['title'].startswith("JSON version of"))

        nerd = self.bag.nerd_metadata_for("trial1.json", True)
        self.assertIn("previewURL", nerd)
        self.assertTrue(nerd['title'].startswith("JSON version of"))
        self.assertTrue(nerd['previewURL'].endswith("trial1.json/preview"))
Example #3
0
    def setUp(self):
        self.tf = Tempfiles()
        self.bagdir = self.tf.track("mbag")
        shutil.copytree(bagdir, self.bagdir)

        self.bag = bag.NISTBag(self.bagdir)
        self.valid8 = val.BagItValidator()
Example #4
0
    def setUp(self):
        self.tf = Tempfiles()
        self.bagdir = self.tf.track("mbag")
        shutil.copytree(bagdir, self.bagdir)

        self.bag = bag.NISTBag(self.bagdir)
        mbtagf = os.path.join(self.bag.multibag_dir, "member-bags.tsv")
        with open(mbtagf, 'w') as fd:
            print(self.bag.name, file=fd)
        mbtagf = os.path.join(self.bag.multibag_dir, "file-lookup.tsv")
        nmre = re.compile(r'samplebag')
        with open(mbtagf) as fd:
            lines = fd.readlines()
        with open(mbtagf, 'w') as fd:
            for line in lines:
                fd.write(nmre.sub(self.bag.name, line))

        self.valid8 = val.MultibagValidator()
Example #5
0
    def setUp(self):
        self.tf = Tempfiles()
        self.bagdir = self.tf.track("XXXX.mbag0_2-0")
        shutil.copytree(bagdir, self.bagdir)

        self.bag = bag.NISTBag(self.bagdir)
        mbtagf = os.path.join(self.bag.multibag_dir, "group-members.txt")
        with open(mbtagf, 'w') as fd:
            print(self.bag.name, file=fd)
        mbtagf = os.path.join(self.bag.multibag_dir, "group-directory.txt")
        nmre = re.compile(r'samplebag')
        with open(mbtagf) as fd:
            lines = fd.readlines()
        with open(mbtagf, 'w') as fd:
            for line in lines:
                fd.write(nmre.sub(self.bag.name, line))

        config = {
            "nerdm_schema_dir": schemadir,
        }

        self.valid8 = val.NISTBagValidator(config)
Example #6
0
 def setUp(self):
     self.bag = bag.NISTBag(bagdir)