def test_item_count(self):
     dexterity_import(self.target,
                      """filename,keywords\ntest1,1""",
                      dict(filename='id', keywords="item_count"),
                      object_type="Document",
                      create_new=True,
                      primary_key='id')
     self.assertIn('test1', self.target.objectIds())
     self.assertEqual(self.target['test1'].item_count, 1)
 def test_list_keywords(self):
     dexterity_import(self.target,
                      """filename,keywords\ntest1,"blah1;blah2" """,
                      dict(filename='id', keywords="subjects"),
                      object_type="Document",
                      create_new=True,
                      primary_key='id')
     self.assertIn('test1', self.target.objectIds())
     self.assertEqual(self.target['test1'].subjects, (u'blah1', u'blah2'))
 def test_invalid_field(self):
     dexterity_import(self.target,
                      """filename,date\ntest1,10/10/2015""",
                      dict(filename='id', date="blah"),
                      object_type="Document",
                      create_new=True,
                      primary_key='id')
     self.assertIn('test1', self.target.objectIds())
     self.assertEqual(getattr(self.target['test1'],'blah',None), None)
 def test_dates(self):
     dexterity_import(self.target,
                      """filename,date\ntest1,10/10/2015""",
                      dict(filename='id', date="effective"),
                      object_type="Document",
                      create_new=True,
                      primary_key='id')
     self.assertIn('test1', self.target.objectIds())
     self.assertEqual(self.target['test1'].effective(), DateTime("2015/10/10"))
 def test_invalid_field(self):
     dexterity_import(self.target,
                      """filename,date\ntest1,10/10/2015""",
                      dict(filename='id', date="blah"),
                      object_type="Document",
                      create_new=True,
                      primary_key='id')
     self.assertIn('test1', self.target.objectIds())
     self.assertEqual(getattr(self.target['test1'], 'blah', None), None)
 def test_item_count(self):
     dexterity_import(self.target,
                      """filename,keywords\ntest1,1""",
                      dict(filename='id', keywords="item_count"),
                      object_type="Document",
                      create_new=True,
                      primary_key='id')
     self.assertIn('test1', self.target.objectIds())
     self.assertEqual(self.target['test1'].item_count, 1)
 def test_url(self):
     dexterity_import(self.target,
                      """url,date\n"http://localhost/plone/target/test1",10/10/2015""",
                      dict(url='_url', date="title"),
                      object_type="Document",
                      create_new=True,
                      primary_key='_url')
     self.assertIn('test1', self.target.objectIds())
     self.assertEqual(getattr(self.target['test1'],'blah',None), None)
 def test_list_contributors(self):
     dexterity_import(self.target,
                      """filename,keywords\ntest1,"blah1;blah2" """,
                      dict(filename='id', keywords="contributors"),
                      object_type="Document",
                      create_new=True,
                      primary_key='id')
     self.assertIn('test1', self.target.objectIds())
     self.assertEqual(self.target['test1'].contributors, (u'blah1', u'blah2'))
    def test_skip(self):

        self.assertNotIn('test1.mp4', self.target.objectIds())
        dexterity_import(self.target,
                         TEST1,
                         dict(Filename='id', Description="description"),
                         object_type="__skip__",
                         create_new=False,
                         primary_key='id')
        self.assertNotIn('test1.mp4', self.target.objectIds())
 def test_dates(self):
     dexterity_import(self.target,
                      """filename,date\ntest1,10/10/2015""",
                      dict(filename='id', date="effective"),
                      object_type="Document",
                      create_new=True,
                      primary_key='id')
     self.assertIn('test1', self.target.objectIds())
     self.assertEqual(self.target['test1'].effective(),
                      DateTime("2015/10/10"))
 def test_url(self):
     dexterity_import(
         self.target,
         """url,date\n"http://localhost/plone/target/test1",10/10/2015""",
         dict(url='_url', date="title"),
         object_type="Document",
         create_new=True,
         primary_key='_url')
     self.assertIn('test1', self.target.objectIds())
     self.assertEqual(getattr(self.target['test1'], 'blah', None), None)
    def test_skip(self):

        self.assertNotIn('test1.mp4', self.target.objectIds())
        dexterity_import(self.target,
                         TEST1,
                         dict(Filename='id', Description="description"),
                         object_type="__skip__",
                         create_new=False,
                         primary_key='id')
        self.assertNotIn('test1.mp4', self.target.objectIds())
 def setUp(self):
     """Custom shared utility setup for tests."""
     self.portal = self.layer['portal']
     self.portal.invokeFactory('Folder', 'target')
     self.target = self.portal.target
     dexterity_import(self.target,
                      TEST1,
                      dict(Filename='id', Description="description"),
                      object_type="Document",
                      create_new=True,
                      primary_key='id')
 def setUp(self):
     """Custom shared utility setup for tests."""
     self.portal = self.layer['portal']
     self.portal.invokeFactory('Folder', 'target')
     self.target = self.portal.target
     dexterity_import(self.target,
                      TEST1,
                      dict(Filename='id', Description="description"),
                      object_type="Document",
                      create_new=True,
                      primary_key='id')
 def test_create(self):
     self.assertNotIn('test1.mp4', self.target.objectIds())
     dexterity_import(self.target,
                      TEST1,
                      dict(Filename='id', Description="description"),
                      object_type="Document",
                      create_new=True,
                      primary_key='id')
     self.assertIn('test1.mp4', self.target.objectIds())
     self.assertEqual(len(self.target.objectIds()), 3)
     self.assertEqual(self.target['test1.mp4'].description, "summary1 blah")
     self.assertEqual(self.target['test2.mp4'].description, "summary2, blah")
    def test_date(self):
        dexterity_import(self.target,
                         """filename,date\ntest1,10/10/2015""",
                         dict(filename='id', date="effective"),
                         object_type="Document",
                         create_new=True,
                         primary_key='id')

        res =  export_file(self.all(),
                            [dict(header='Filename', field='id'),
                             dict(header='date',field="effective")],
                            None)
        self.assertIn("test1,2015-10-10 00:00:00", res)
 def test_create(self):
     self.assertNotIn('test1.mp4', self.target.objectIds())
     dexterity_import(self.target,
                      TEST1,
                      dict(Filename='id', Description="description"),
                      object_type="Document",
                      create_new=True,
                      primary_key='id')
     self.assertIn('test1.mp4', self.target.objectIds())
     self.assertEqual(len(self.target.objectIds()), 3)
     self.assertEqual(self.target['test1.mp4'].description, "summary1 blah")
     self.assertEqual(self.target['test2.mp4'].description,
                      "summary2, blah")
    def test_date(self):
        dexterity_import(self.target,
                         """filename,date\ntest1,10/10/2015""",
                         dict(filename='id', date="effective"),
                         object_type="Document",
                         create_new=True,
                         primary_key='id')

        res = export_file(self.all(), [
            dict(header='Filename', field='id'),
            dict(header='date', field="effective")
        ], None)
        self.assertIn("test1,2015-10-10 00:00:00", res)
    def test_update(self):
        self.assertNotIn('test1.mp4', self.target.objectIds())
        dexterity_import(self.target,
                         TEST1,
                         dict(Filename='id', Description="description"),
                         object_type="Document",
                         create_new=True,
                         primary_key='id')
        self.assertIn('test1.mp4', self.target.objectIds())
        self.assertEqual(len(self.target.objectIds()), 3)

        dexterity_import(self.target,
                         """Filename,Series,Description
test1.mp4,1,new summary
""",
                         dict(Filename='id', Description="description"),
                         object_type="Document",
                         create_new=True,
                         primary_key='id')
        self.assertEqual(self.target['test1.mp4'].description, "new summary")
    def test_update(self):
        self.assertNotIn('test1.mp4', self.target.objectIds())
        dexterity_import(self.target,
                         TEST1,
                         dict(Filename='id', Description="description"),
                         object_type="Document",
                         create_new=True,
                         primary_key='id')
        self.assertIn('test1.mp4', self.target.objectIds())
        self.assertEqual(len(self.target.objectIds()), 3)

        dexterity_import(self.target,
                         """Filename,Series,Description
test1.mp4,1,new summary
""",
                         dict(Filename='id', Description="description"),
                         object_type="Document",
                         create_new=True,
                         primary_key='id')
        self.assertEqual(self.target['test1.mp4'].description, "new summary")