Last active
November 25, 2016 14:59
-
-
Save Hateman31/e525bf6b09954408c508837ff717ee03 to your computer and use it in GitHub Desktop.
generating case-expression
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import unittest | |
| def get_cases(fields): | |
| res = [] | |
| return res | |
| def get_fields_from_str(): | |
| pass | |
| if __name__ == "__main__": | |
| class TestMakingCases(unittest.TestCase): | |
| def setUp(self): | |
| self.case_str = "case when 1 in (data.Q1$1,data.Q1$2) then 1 else 0 end Q1_m1" | |
| self.fields = ['data.Q1$1','data.Q1$2'] | |
| def test_stripFields(self): | |
| fields_str = """ | |
| data.Q1$1, | |
| data.Q1$2 | |
| """ | |
| fields = get_fields_from_str(fields_str) | |
| self.assertEqual(fields,self.fields) | |
| def test_getCases(self): | |
| cases = get_cases(self.fields) | |
| self.assertEqual(cases[0],self.case_str) | |
| unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment