Exemple #1
0
    def test5(self):
        ms = MemoryStore()
        ub = UserBase(ms)
        
        u = ub.newuser('someuid')
        u.setfield('field', 'value')
        
        fields = ms.readuser('someuid')
        self.assertIsNone(fields)
        
        ub.store_changes()
        
        fields = ms.readuser('someuid')
        self.assertEqual(fields.get('field'), 'value')

        u.setfield('field', 'newvalue')
        ub.store_changes()
        
        fields = ms.readuser('someuid')
        self.assertEqual(fields.get('field'), 'newvalue')
Exemple #2
0
def main(argv):
    args = parser.parse_args()

    if args.test:
        print "Testing"
        mg = MockGithub()
        ms = MemoryStore()
        qs = MemoryStore()
        rc = RepoCollector(mg, ms, qs)
        rc.enqueue(10, 10000)
        rc.execute_all()
        result = ms.get_stored()
        expected = mg.get_raw_repos(10, 10000)
        if len(result) != len(expected):
            raise Exception("Length of result and expected differs")
        if set(result) != set(expected):
            raise Exception("Contents of result and expected differs")
        print "OK"
        return

    cur_time = datetime.datetime.now().isoformat()
    filename = "repos." + cur_time
    queuename = "queue"
    relpath = "collection/" + filename
    latestrelpath = "collection/repos.latest"

    if os.path.exists(latestrelpath):
        os.unlink(latestrelpath)
    os.symlink(filename, latestrelpath)
    gh = GithubAPIWrapper(args.user, args.password)
    if os.path.exists(queuename):
        rc = RepoCollector(gh, AppendStore(relpath), OverwriteStore(queuename))
        rc.load_queue()
    else:
        rc = RepoCollector(gh, AppendStore(relpath), OverwriteStore(queuename))
        rc.enqueue(100, 100000)
    rc.execute_all()
Exemple #3
0
 def test1(self):
     s = MemoryStore()
     
     s.storeuser('*****@*****.**', {'field1':'value1', 'field2':'value2'})
     
     fields = s.readuser('*****@*****.**')
     
     self.assertDictEqual(fields, {'field1':'value1', 'field2':'value2'})
     self.assertTrue(s.userexists('*****@*****.**'))
     
     s.storeuser('*****@*****.**', {'field3':'value3'})
     
     fields = s.readuser('*****@*****.**')
     
     self.assertDictEqual(fields, {'field3':'value3'})
     self.assertTrue(s.userexists('*****@*****.**'))
     
     s.deluser('*****@*****.**')
     
     self.assertFalse(s.userexists('*****@*****.**'))