Skip to content

Commit

Permalink
test(GHAnalysis.py): add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Stareven233 committed Sep 16, 2020
1 parent ef017bc commit 6bdc318
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import unittest
import os
from GHAnalysis import Data


class TestGHA(unittest.TestCase):

def setUp(self):
self.data = Data()
self.assertIsInstance(self.data, Data)

def tearDown(self):
pass

def test_init(self):
self.data.init('./data')
# 此时数据为 4份2020-01-01-15.json + 1份2015-01-01-15.json
file_exist = all((os.path.exists(f'{i}.pkl') for i in range(3)))
self.assertTrue(file_exist)

def test_user_event(self):
self.data.load()
num = self.data.user_events.get('waleko', {}).get('PushEvent', 0)
self.assertEqual(num, 8)

def test_repo_event(self):
self.data.load()
num = self.data.repo_events.get('katzer/cordova-plugin-background-mode', {}).get('PushEvent', 0)
self.assertEqual(num, 0)

def test_user_repo_event(self):
self.data.load()
num = self.data.user_repo_events.get('cdupuis', {}).get('atomist/automation-client', {}).get('PushEvent', 0)
self.assertEqual(num, 4)


if __name__ == '__main__':
unittest.main()

0 comments on commit 6bdc318

Please sign in to comment.