Commits

Anonymous committed 2508c56

add new test for the store.py modules

  • Participants
  • Parent commits 6897feb

Comments (0)

Files changed (5)

 
 # buildout
 .installed.cfg
+envs
 bin
 develop-eggs
 downloads
      WSGIUtils
      BeautifulSoup
      coverage
+     ipdb
      pypi
+extra-path = /Users/marrakis/Documents/cyrilrbt.pypi/envs/lib/python2.6/site-packages/distutils2/
 
 [nose]
 recipe = pbp.recipe.noserunner
 
         # extract the Trove classifiers
         classifiers = info.get('classifiers', [])
-        classifiers.sort()
 
         # now see if we're inserting or updating a release
         message = None

tests/.coverage

Binary file modified.

tests/test_store.py

+import distutils2
+
+from distutils2.metadata import DistributionMetadata
+
 import os
 import unittest
 import config
+import pkg_resources
+import cStringIO
+
+
 import store
 import trove
 
 
     def tearDown(self):
         self.store.close()
-    
+
+    def test_store_package(self):
+        PKG_INFO = os.path.join(DATA_DIR, 'PKG-INFO')
+        metadata = DistributionMetadata(PKG_INFO)
+        metadata = dict(metadata.items())
+        packages = self.store.get_package("pypi", "0.1")
+
+        self.assertRaises(TypeError, packages.values) 
+        self.store.store_package("pypi", "0.1", metadata)
+
+        packages = self.store.get_package("pypi", "0.1")    
+        assert len(packages.values()) == 21
+
+        packages = self.store.get_package("pypi", "0.2")
+        self.assertRaises(TypeError, packages.values) 
+
+        package = self.store.store_package("pypi", "0.1", metadata)
+        assert package is None
+
+        metadata['author'] = 'Foo'
+        package = self.store.store_package("pypi", "0.1", metadata)
+
+        assert package is not None
+
     def test_create_user(self):        
         self.store.store_user(*user1)
-        self.failIf(self.store.get_user("user1") == None)
+
+        assert self.store.get_user("user1") is not None
         self.assertRaises(ValueError, self.store.store_user, *user2)
 
     def test_get_users(self):
 
     def test_sshkeys(self):
         self.store.store_user(*user1)
-        self.assertEqual(len(self.store.get_sshkeys('user1')), 0)
+        assert len(self.store.get_sshkeys('user1')) == 0
+
         self.store.add_sshkey('user1', "sfasfaf")
-        self.assertEqual(len(self.store.get_sshkeys('user1')), 1)
+        assert len(self.store.get_sshkeys('user1')) == 1
+
         self.store.delete_sshkey(self.store.get_sshkeys('user1')[0].values()[0])
-        self.assertEqual(len(self.store.get_sshkeys('user1')), 0)
+        assert len(self.store.get_sshkeys('user1')) == 0
 
     def test_get_openid(self):
         self.store.store_user(*user1)
-        self.assertEqual(len(self.store.get_openids('user1')), 0)
+        assert len(self.store.get_openids('user1')) == 0
+
         self.store.associate_openid('user1', 'openid_user1')
-        self.assertEqual(len(self.store.get_openids('user1')), 1)
+        assert len(self.store.get_openids('user1')) == 1
 
     def test_get_user_by_openid(self):
         self.store.store_user(*user1)
-        self.assertFalse('user1' in self.store.get_user_by_openid('openid_user1'))
+        assert 'user1' not in self.store.get_user_by_openid('openid_user1')
+
         self.store.associate_openid('user1', 'openid_user1')
-        self.assertTrue('user1' in self.store.get_user_by_openid('openid_user1'))
+        assert 'user1' in self.store.get_user_by_openid('openid_user1')
+
         self.store.drop_openid('openid_user1')
-        self.assertFalse('user1' in self.store.get_user_by_openid('openid_user1'))
+        assert 'user1' not in self.store.get_user_by_openid('openid_user1')
     
 #     def test_openid_provider(self):
 #         self.assertTrue(False)