added new rubiconLite adapter#740
Conversation
|
Looks like you have a unit test failure. Once it's addressed I'll review. |
fb40fc1 to
8731f4e
Compare
8731f4e to
6aa90a3
Compare
|
@mkendall07 should be good now. saucelabs didn't like my mocked |
mkendall07
left a comment
There was a problem hiding this comment.
@snapwich
Thanks for the PR. I've put some initial comments for you to review/address. I'll validate bids after updates. Thanks.
src/adapters/rubiconLite.js
Outdated
| * @file Rubicon (RubiconLite) adapter | ||
| */ | ||
|
|
||
| var CONSTANTS = require('../constants.json'); |
There was a problem hiding this comment.
We prefer now to use the ES6 import syntax. See https://github.com/prebid/Prebid.js/blob/master/src/adapters/appnexusAst.js for examples
src/adapters/rubiconLite.js
Outdated
| var bidfactory = require('../bidfactory.js'); | ||
| var ajax = require("../ajax.js").ajax; | ||
|
|
||
| function RubiconAdapter(mockResponse) { |
There was a problem hiding this comment.
I'm not clear why mockResponse is passed to the constructor function?
There was a problem hiding this comment.
It was my method of testing only the ajax callback in unit tests. It could be written in a way to expose the callback as an export. Do you have a preference?
src/adapters/rubiconLite.js
Outdated
| } | ||
|
|
||
| //indicate that there is no bid for this placement | ||
| let badBid = bidfactory.createBid(2, bid); |
There was a problem hiding this comment.
use CONSTANTS.STATUS.NO_BID instead of 2.
src/adapters/rubiconLite.js
Outdated
| } | ||
|
|
||
| let _renderCreative = (script, impId) => | ||
| '<html>\n' + |
There was a problem hiding this comment.
Prefer ES6 template literals here.
src/adapters/rubiconLite.js
Outdated
| } | ||
|
|
||
| //set the status | ||
| bidRequest.status = CONSTANTS.STATUS.GOOD; |
There was a problem hiding this comment.
this doesn't actually do anything. Please use CONSTANTS.STATUS.GOOD on line 174 instead.
src/adapters/rubiconLite.js
Outdated
| '<\/body>\n' + | ||
| '<\/html>'; | ||
|
|
||
| //expose the callback to the global object: |
There was a problem hiding this comment.
nit: this comment isn't really accurate.
|
submitted updates |
|
Thanks @snapwich |
|
I can't think of any other methods to test the ajax callback in isolation without either passing in a testing dependency or exposing some private methods as exports, both of which require extra code within the module that is really only for testing. Do you have a preference? |
|
right that's because ES6 modules are read only which is a pain. To get around these, we used |
|
Unfortunately mocking the AJAX call is insufficient to test the callback in isolation since the only access is through callBids. Isolation is pretty important in this case I think due to the fact that we have a lot more response handling tests than request sending tests. Without isolation it requires the response handling tests to run the request handling code with each test which is both slow and prone to causing all response tests to fail from request bugs (which makes debugging difficult). I recognize the way I have it now isn't even completely isolated since the test call is still made through callBids (although quickly directed to the callback). I think the ideal situation, and what I've done in the past, is to pass a testing flag using the Webpack DefinePlugin. This allows testing code to be present in the module |
|
@snapwich
We tend to subscribe to "test behaviors, not implementations" concept. If your in a situation where you find yourself having to test private methods, you are unit testing implementation vs public interface. Here's a link: https://teamgaslight.com/blog/testing-behavior-vs-testing-implementation I'm not sure if writing conditionals into the code for test/prod is more desirable than the current way you are doing it. What this means practically, is that you should be able to test what is needed by the public interface by mocking out dependencies as needed. |
I agree with your statement and the article you've provided. Unfortunately AJAX has the side-effect of exposing an additional API which is public in the sense that an external resource has to communicate with our internal implementation. By "exposing" that hidden API in the way prescribed (fake server responses) it is requiring the unit tests to execute a lot of additional code that is not under test which has negative consequences for both testing performance and false-positives when not-under-test-code has bugs. However, in interest of moving forward, I've made the recommendation here as suggested. I hope you'll consider allowing testing and debugging code paths in the future for builds as I have seen many positive benefits in the past. |
|
thanks for the update.
I'm hesitant to allow it because I think it can encourage bad behavior "it's OK because it's test code and thrown away anyway" type of attitude. Not that it cannot be done right. We'll always consider other's viewpoints on these things. Thanks for contributing. |
…ebid-0.14.0 to release/1.7.0 * commit '3eefcf043466f5457c81bfec18b032b53490b78b': (52 commits) New adapters ids. Prebid 0.14.0 Release add workaround to prevent IX adapter from ending auction earlier due to one request becoming many responses (prebid#763) Add pbjs.getHighestCpmBids for getting winning bids (prebid#755) Fix build Drop Sekindo adapter. Bugfix/suppress prebid request if sizeMapping undefined for device width (prebid#758) amp integration (prebid#756) Add contribution guidelines (prebid#761) Add api method to shuffle the order bidders are called in (prebid#760) build adapter from custom source path (prebid#753) reduce duplication and ignore ga.js in coverage (prebid#754) Log /ut response errors in dev console (prebid#747) Fix indentation (code style error when building) (prebid#751) Add package keywords (prebid#746) added new rubiconLite adapter (prebid#740) Show warning if bidCpmAdjustment is set for AOL bidder (closes prebid#725) (prebid#728) IX adapter code refactoring (prebid#711) Update memeglobal.js (prebid#737) Pulsepoint Analytics adapter for Prebid (prebid#706) ...
…7.0 to master * commit '262f371a5c855419c3ef357fb1f0cf87a107749f': (52 commits) New adapters ids. Prebid 0.14.0 Release add workaround to prevent IX adapter from ending auction earlier due to one request becoming many responses (prebid#763) Add pbjs.getHighestCpmBids for getting winning bids (prebid#755) Fix build Drop Sekindo adapter. Bugfix/suppress prebid request if sizeMapping undefined for device width (prebid#758) amp integration (prebid#756) Add contribution guidelines (prebid#761) Add api method to shuffle the order bidders are called in (prebid#760) build adapter from custom source path (prebid#753) reduce duplication and ignore ga.js in coverage (prebid#754) Log /ut response errors in dev console (prebid#747) Fix indentation (code style error when building) (prebid#751) Add package keywords (prebid#746) added new rubiconLite adapter (prebid#740) Show warning if bidCpmAdjustment is set for AOL bidder (closes prebid#725) (prebid#728) IX adapter code refactoring (prebid#711) Update memeglobal.js (prebid#737) Pulsepoint Analytics adapter for Prebid (prebid#706) ...
…ly_prebid_8_upgrade Revert "Updated wiid with unique string instead of auction id"
Type of change
Description of change
This is a lightweight Rubicon adapter that no longer includes the Fastlane library when participating in an auction. Due to the lack of Fastlane library, some APIs are unavailable (such as those on the
rubicontag). For those who still require access to those APIs they can use the regularrubiconadapter; for those that don't need those APIs, there is now the option to use thisrubiconLiteadapter for a performance increase.