#django

/

      • raijin has quit
      • reisio joined the channel
      • ironfroggy has quit
      • lastmanstanding joined the channel
      • lastmanstanding has quit
      • flebel has quit
      • Croves has quit
      • flebel joined the channel
      • the_rat joined the channel
      • ironfroggy joined the channel
      • royendgel has quit
      • whaack joined the channel
      • whaack has quit
      • EyePulp has quit
      • whaack joined the channel
      • the_rat has quit
      • jfisk87 has quit
      • darylantony joined the channel
      • whaack has quit
      • jessamynsmith has quit
      • jfisk87 joined the channel
      • royendgel joined the channel
      • jhfisc has quit
      • jhfisc joined the channel
      • ironfroggy has quit
      • cyphase joined the channel
      • ironfroggy joined the channel
      • whaack joined the channel
      • jhfisc has quit
      • deltaskelta has quit
      • sebastian-w has quit
      • sebastian-w joined the channel
      • jhfisc joined the channel
      • whaack has quit
      • rpkilby joined the channel
      • iiie has quit
      • ubuntu_aze has quit
      • darylantony has quit
      • tulioz has quit
      • darylantony joined the channel
      • ironfroggy has quit
      • ironfroggy joined the channel
      • ubuntu_aze joined the channel
      • ironfroggy has quit
      • ironfroggy joined the channel
      • watersoul_ joined the channel
      • ironfroggy has quit
      • barajasfab joined the channel
      • aossama has quit
      • zeograd has quit
      • pokEarl has quit
      • cnu has quit
      • jhfisc has quit
      • waveclaw joined the channel
      • greydawg joined the channel
      • transit has left the channel
      • dodobas has quit
      • aossama joined the channel
      • koniiiik has quit
      • yonatankoren_ has quit
      • jhfisc joined the channel
      • jfisk87 has quit
      • djdduty joined the channel
      • glassresistor joined the channel
      • ghostlight has quit
      • glassresistor
        i've been working on an OS app for a while now and am having trouble getting tests to pass b/c i have to use @override_settings to set which model to serve as an api
      • Koterpillar
        glassresistor: please continue
      • glassresistor
        i have a function called get_search_model and use it everywhere which returns the model set in settings
      • Koterpillar: here is the get_search_model code https://github.com/codeforamerica/wealthmap/blo...
      • yonatankoren joined the channel
      • now in tests i override this to use an ExampleOpportunity which is a model in the app itself like so https://github.com/codeforamerica/wealthmap/blo...
      • cyphase joined the channel
      • cnu joined the channel
      • raijin joined the channel
      • zeograd joined the channel
      • this is of course the doucmented way to do it but because what im doing is effectively lettings a project swap out the model used by forms and restframework
      • im getting bad results
      • Koterpillar
        how do you define "bad results" and what do they have to do with this setting?
      • ghostlight joined the channel
      • glassresistor
        Koterpillar: im getting there sorry
      • Koterpillar: now when i run my tests with the settings defined the same as the override the tests pass just fine but when i use settings different from the override i get lots of errors
      • krfa has quit
      • OtherAllan has quit
      • Koterpillar: the settings defines what model a restframework api will use
      • Ankhers joined the channel
      • Koterpillar: i've done a bit of debugging but add these two lines of code to the get_search_model function and running my tests
      • print(search_model)
      • import inspect ; print(inspect.stack()[1])
      • Sonderblade has quit
      • raijin has quit
      • and the results look like this http://pastebin.com/2gKqFLTz
      • raijin joined the channel
      • reisio has quit
      • so what im setting is that even though once the tests themselves are running the overrides are taking effect but during the initial setup phase its using the settings defined in the settings file
      • Koterpillar
        can I see matcher/forms.py?
      • glassresistor
        so the forms, admin, and serializers all get defined with the projects settings instead of the tests settings
      • Koterpillar
        also, raise an exception instead, you'll get a full stack trace
      • barajasfab has quit
      • koniiiik joined the channel
      • glassresistor
        Koterpillar: sure although in this case the form and admin are not part of the main app but rather the project and its the serializers with the wrong settings being the issue
      • Koterpillar: here they are though https://github.com/codeforamerica/longbeach-res...
      • Koterpillar: its just used for the admin
      • Koterpillar
        oh, I see
      • bsl10 has quit
      • can you avoid it on module load?
      • actually, this means you can't import any of those things before apps are loaded
      • glassresistor
        Koterpillar: not sure the serializers have to load on module load because thats how restframework does it, same with forms/admin(luckily those dont matter for this case)
      • Koterpillar: so i don't think i can force the serializers to load when the views are called because the serializers are collected and cahed similar to how models are to avoid circular dependencies
      • GuyYotine joined the channel
      • Koterpillar
        can you still raise an exception and paste the traceback from when you run tests?
      • glassresistor
        Koterpillar: i've got the sinking feeling the only solution is to have django allow for an app to change settings before the models load but i don't think thats doable for many reasons
      • Koterpillar: the pastebin includes all of the tracebacks from the tests
      • Koterpillar
        no, raise an exception in get_search_model
      • SecondForm_Glenn has quit
      • glassresistor
        Koterpillar: sure i mean i was basically doing that just by printing the stack()[1] in the test output but and ill want to skip the errors because the 3rd call is the interesting one to serializers
      • Koterpillar
        no
      • you get the bottom of each trace
      • I want the entirety of one trace
      • glassresistor
        ok one sec
      • Genitrust has quit
      • Sonderblade joined the channel
      • Koterpillar
        (it could be just inspect.stack(), but that's hard to read)
      • djdduty has quit
      • Genitrust joined the channel
      • djdduty joined the channel
      • also, raw links from pastebin.com look better
      • ubuntu_aze has quit
      • glassresistor
        Koterpillar: thanks im working making something that looks nice
      • Genitrust has quit
      • felixx joined the channel
      • royendgel has quit
      • cssko joined the channel
      • delgiudices joined the channel
      • cyphase joined the channel
      • k3va has quit
      • c17r_ has quit
      • Genitrust joined the channel
      • Koterpillar: here the full trace http://pastebin.com/raw/vHCVwxcC
      • Koterpillar
        hmm, so this is after the settings and apps are loaded
      • this won't generally work with override_settings
      • glassresistor
        Koterpillar: exactly
      • Koterpillar
        because the value is effectively cached, rather than used each time
      • are tests your only problem?
      • glassresistor
        Koterpillar: the application works great and i like the design but im not sure of a way to make the tests work outside of the sample project
      • Koterpillar: yep
      • Koterpillar
        well, if you were to test this app as a library you'd set the settings right globally
      • if you are testing this as part of a django project, you don't have a choice
      • glassresistor
        Koterpillar: is there a way of testing an application without a sample_project? there didn't used to be
      • Koterpillar
        always was
      • glassresistor
        Koterpillar: really?