import unittest
from main import *

hash_scan_response = '{"permalink": "https://www.virustotal.com/file/54bc950d46a0d1aa72048a17c8275743209e6c17bdacfc4c' \
                     'b9601c9ce3ec9a71/analysis/1513948343/", "response_code": 1, "sha256": "54bc950d46a0d1aa72048a17' \
                     'c8275743209e6c17bdacfc4cb9601c9ce3ec9a71", "resource": "7657fcb7d772448a6d8504e4b20168b8", ' \
                     '"scan_id": "54bc950d46a0d1aa72048a17c8275743209e6c17bdacfc4cb9601c9ce3ec9a71-1513948343"}'
hash_scan_response_clean = '{"permalink": "https://www.virustotal.com/file/54bc950d46a0d1aa72048a17c8275743209e6c17b' \
                           'dacfc4cb9601c9ce3ec9a71/analysis/1513948343/", "response_code": 0, "sha256": "54bc950d46a' \
                           '0d1aa72048a17c8275743209e6c17bdacfc4cb9601c9ce3ec9a71", "resource": "7657fcb7d772448a6d85' \
                           '04e4b20168b8", "scan_id": "54bc950d46a0d1aa72048a17c8275743209e6c17bdacfc4cb9601c9ce3ec9a' \
                           '71-1513948343"}'
file_report_response_malicious = '{"positives": 64, "total": 68}'
file_report_response_clean = '{"positives": 0, "total": 68}'


class TestMain(unittest.TestCase):

    def test_malicious_file_scan_response(self):
        self.assertEqual(get_response_code(hash_scan_response), 1)

    def test_clean_file_scan_response(self):
        self.assertEqual(get_response_code(hash_scan_response_clean), 0)

    def test_if_malicious_file_is_detected(self):
        self.assertEqual(is_file_malicious(parse_response(file_report_response_malicious)), True)

    def test_is_clean_file_is_detected(self):
        self.assertEqual(is_file_malicious(parse_response(file_report_response_clean)), False)


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